package xyz.cfg

import java.util.{ Map => Jm, HashMap => Hm }
import java.util.{HashMap => Hm}
import java.util.{Map => Jm}

class Cfg {
  var entry: Map[String, String] = Map[String, String]()

  def getString(path: String): String = entry.get(path).get

  def getInt(path: String): Int = getString(path).toInt
  def getLong(path: String): Long = getString(path).toLong
  def getDouble(path: String): Double = getString(path).toDouble
  def getFloat(path: String): Float = getString(path).toFloat
  def getByte(path: String): Byte = getString(path).toByte
  def getChar(path: String): Char = getString(path).toCharArray()(0)
  def getShort(path: String): Short = getString(path).toShort
  def getBoolean(path: String): Boolean = {
    val str: String = getString(path)
    str.equalsIgnoreCase("true") || str == "1"
  }

  def jentry(): Jm[String, String] = {
    val res: Jm[String, String] = new Hm[String, String]
    for (key <- entry.keys) {
      val value: String = getString(key)
      res.put(key, value)
    }
    res
  }

  def add(path: String, cfgVal: String) {
    entry += (path -> cfgVal)
  }
}

